using System;
using Microsoft.SharePoint;

namespace Aks.Deployment.SharePoint.Extensions
{
	/// <summary>
	/// Extension methods for the <see cref="SPWeb"/> class.
	/// </summary>
	public static class SPWebExtension
	{
		private const string MasterPageGalleryNotFoundError = "Master page gallery could not be found.";


		/// <summary>
		/// Gets the master page gallery from the specified <paramref name="web"/>.
		/// </summary>
		/// <param name="web">The site to get the master page gallery from.</param>
		/// <returns>The master page gallery.</returns>
		public static SPList GetMasterPageGallery(this SPWeb web)
		{
			// TODO: Replace this with a reference to the language resource
			var list = web.Lists["Master Page Gallery"];
			if (list == null)
			{
				throw new InvalidOperationException(MasterPageGalleryNotFoundError);
			}
			return list;
		}
	}
}